package com.example.batchprocessing;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;

/**
 * A common paradigm in batch processing is to ingest data, transform it,
 * and then pipe it out somewhere else. Here, you need to write a simple transformer
 * that converts the names to uppercase.
 */
public class PersonItemProcessor  implements ItemProcessor <Person, Person>{
    private static final Logger log = LoggerFactory.getLogger(PersonItemProcessor.class);


    @Override
    public Person process(Person person) throws Exception {
        String firstName = person.getFirstName().toUpperCase();
        String lastName = person.getLastName().toUpperCase();
        Person transformedPerson = new Person(firstName, lastName);
        log.info("Converting (" + person +") into (" + transformedPerson + ")");
        return transformedPerson;
    }
}
